/********************************************************
*  Monica Jimenez Anton                                 *
*  Juan Luis Martinez Cesteros                          *
*  Practicas - IGr                                     *
********************************************************/
#ifndef GLSkel3DH
#define GLSkel3DH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <gl\gl.h>
#include <gl\glu.h>
#include "Camara.h"
#include "Habitacion.h"
//---------------------------------------------------------------------------
enum t_estado_camara{perspectiva,ortogonal,oblicua,ninguna};
enum t_movimiento{mesa,estanteria,lampara,persona};
enum t_transformacion{desplazar,rotar,escalar};
class TGLForm3D : public TForm
{
__published:	// IDE-managed Components
        TMainMenu *MainMenu1;
        TMenuItem *Camara1;
        TMenuItem *Proyeccion1;
        TMenuItem *Ortogonal1;
        TMenuItem *Perspectiva1;
        TMenuItem *Oblicua1;
        TMenuItem *Vista1;
        TMenuItem *Esquina1;
        TMenuItem *Lateral1;
        TMenuItem *Frontal1;
        TMenuItem *Cenital1;
        TMenuItem *Normal1;
        TTimer *Timer1;
        TMenuItem *Simulacionlumnica1;
        TMenuItem *Acelerar1;
        TMenuItem *Disminuir1;
        TMenuItem *Parar1;
        TMenuItem *Bombilla1;
        TMenuItem *Mobiliario1;
        TMenuItem *Puerta1;
        TMenuItem *Persiana;
        TMenuItem *Entornarlapersiana1;
        TMenuItem *Estilos1;
        TMenuItem *Normal2;
        TMenuItem *Old1;
        TMenuItem *Controldemovimiento1;
        TMenuItem *Persona1;
        TMenuItem *Lmpara1;
        TMenuItem *Mesa1;
        TMenuItem *Estanteria1;
        TMenuItem *Transformaciones1;
        TMenuItem *Desplazar1;
        TMenuItem *Rotar1;
        TMenuItem *Escalar1;
    void __fastcall FormResize(TObject *Sender);
    void __fastcall FormPaint(TObject *Sender);
    void __fastcall FormDestroy(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);
  
        void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall Ortogonal1Click(TObject *Sender);

        void __fastcall Perspectiva1Click(TObject *Sender);
        void __fastcall Oblicua1Click(TObject *Sender);
        void __fastcall Esquina1Click(TObject *Sender);
        void __fastcall Lateral1Click(TObject *Sender);
        void __fastcall Frontal1Click(TObject *Sender);
        void __fastcall Cenital1Click(TObject *Sender);
        void __fastcall Normal1Click(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall Acelerar1Click(TObject *Sender);
        void __fastcall Disminuir1Click(TObject *Sender);
        void __fastcall Parar1Click(TObject *Sender);
        void __fastcall Bombilla1Click(TObject *Sender);
        void __fastcall Puerta1Click(TObject *Sender);
        void __fastcall PersianaClick(TObject *Sender);
        void __fastcall Entornarlapersiana1Click(TObject *Sender);
        void __fastcall Old1Click(TObject *Sender);
        void __fastcall Normal2Click(TObject *Sender);
        void __fastcall Lmpara1Click(TObject *Sender);
        void __fastcall Persona1Click(TObject *Sender);
        void __fastcall Mesa1Click(TObject *Sender);
        void __fastcall Estanteria1Click(TObject *Sender);
        void __fastcall Desplazar1Click(TObject *Sender);
        void __fastcall Rotar1Click(TObject *Sender);
        void __fastcall Escalar1Click(TObject *Sender);

private:        // User declarations
    HDC hdc;
    HGLRC hrc;
    
    GLdouble RatioViewPort, xLeft,xRight, yBot,yTop, N,F;  // volumen de vista
    GLfloat PosicionSol[4];
    GLfloat PosicionBombilla[4];
    TAfin *marco_bombilla;
    Camara *camara;
    Habitacion * habitacion;

    //valores para las vistas de camara
    enum t_estado_camara estado_camara;

    GLfloat angulo;
    GLfloat proporcion;
    PV * dir;

    //valores para la iluminacion
    GLfloat luz;
    bool aumentandoluz;
    bool bombilla;

    //valores del mobiliario
    bool puerta_abierta;
    bool persiana_abierta;
    bool persiana_entornada;

    //control del moviento
    enum t_movimiento movimiento;
    enum t_transformacion transformaciones;

    void __fastcall SetPixelFormatDescriptor();
    void __fastcall GLScene();
    void crearObjetosEscena();

    void liberarObjetosEscena();
    void crearIluminacionEscena();



public:		// User declarations
    __fastcall TGLForm3D(TComponent* Owner);
    void moverCamara(char tecla);
    void moverObjetos(TAfin *obj,PV* desp, PV * rot, PV* sc);
    void calculaPosicionBombilla(PV* desp, PV * rot, PV* sc);
};
//---------------------------------------------------------------------------
extern PACKAGE TGLForm3D *GLForm3D;
//---------------------------------------------------------------------------
#endif
